﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Bussiness;
using Data;
using System.Text.RegularExpressions;

namespace hostal
{
    public partial class AgregarPais : Form
    {
        public AgregarPais()
        {
            InitializeComponent();
        }

        private void BTCancelar_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void BTAceptar_Click(object sender, EventArgs e)
        {
            if(!TBNombrePais.Equals(null))
            {
                TBNombrePais.Text = Regex.Replace(TBNombrePais.Text, @"\s+", " "); 
                PaisDataAccess agregarPais = new PaisDataAccess();
                if (agregarPais.agregarNuevoPais(TBNombrePais.Text.Trim()))
                {
                    MessageBox.Show("Registro Exitoso");
                    this.Close();
                }
                else
                    MessageBox.Show("No Se Pudo Registrar");
            }
        }

        private void TBNombrePais_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Validador.validarLetraConEspacio(e.KeyChar))
                e.Handled = false;
            else
                e.Handled = true;
        }
    }
}
